﻿using RpcHelper;
using SqlExecHelper;
using SqlExecHelper.SetColumn;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Service.DAL
{
        internal class DictateNodeDAL : SqlBasicClass
        {
                public DictateNodeDAL () : base ("DictateNode", "RpcExtendService")
                {

                }
                public long Add (DictateNewNode add)
                {
                        base.Insert (add, out long id);
                        return id;
                }
                public void Drop (long[] ids)
                {
                        base.Drop<long> ("Id", ids);
                }
                public DictateNode[] Gets ()
                {
                        return base.Get<DictateNode> ();
                }
                public DictateNode Get (long id)
                {
                        return base.GetRow<long, DictateNode> ("Id", id);
                }
                public DictateNode[] Gets (long[] ids)
                {
                        return base.Get<long, DictateNode> ("Id", ids);
                }
                public void Set (long id, string name)
                {
                        if (!base.Update (new ISqlSetColumn[] {
                                new SqlSetColumn("DictateName", System.Data.SqlDbType.NVarChar,50){ Value=name}
                        }, "Id", id))
                        {
                                throw new ErrorException ("rpc.dictate.node.set.fail");
                        }
                }
        }
}
